package com.user.mapper;

import com.api.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/*
    @ClassName UserMapper
    @Description TODO
    @Date 2021/8/31、10:25
*/
@Repository
@Mapper
public interface UserMapper extends BaseMapper<User> {

    //验证登录
    @Select("select * from user where phone = #{phone} and password = #{password}")
    User checkUser(User user);

    //注册
    @Insert("insert into user(name,phone,password,reg_ip) values('泡泡新人',#{phone},#{password},#{regIp})")
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
    void addUser(User user);

    //验证手机号
    @Select("select * from user where phone = #{phone}")
    Integer checkPhone(String phone);

    //修改昵称、头像
    void updateUser(@Param("id") int id,@Param("name") String name,@Param("fileId") String fileId);

    //修改密码
    @Update("update user set password = #{pwd} where id = #{id}")
    void updatePwd(int id,String pwd);


}
